<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>[[${appName}]] - [[${server}]]
    </title>
    <link type="text/css" rel="stylesheet" th:href="@{${skinPath} + '/css.css'}"/>
    <style type="text/css">
        body {
            margin-top: 0px;
            margin-bottom: 0px;
        }
        body, td, th {
            font-size: 14px;
        }
    </style>
    <link href="index.css" rel="stylesheet" type="text/css">
    <script th:src="@{/inc/common.js}"></script>
    <script th:src="@{/js/jquery-1.9.1.min.js}"></script>
    <script th:src="@{/js/jquery-migrate-1.2.1.min.js}"></script>
</head>
<body>
<div style="text-align:center;margin:20px">
    <input type="button" value="上一步" class="btn btn-default" onclick="window.location.href='dataDict'"/>&nbsp;&nbsp;
    <strong>请选择对应其它系统的数据源</strong>
    <select id="dbSource" name="dbSource">
        <option value="">请选择</option>
        <option th:each="di : ${diInfo}"
                th:value="${di.name}"
                th:selected="${di.isDefault}"
                th:text="${di.name}">
        </option>
    </select>
    <script th:inline="javascript">
        o('dbSource').value = [[${dbSource}]];
    </script>
    &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;"
                               onclick="if ('oa'==$('#dbSource').val()) {alert('不能修改默认的数据源oa'); return;} openWin('dbConnEdit?dbSource=' + $('#dbSource').val(), 640, 480)">修改数据源</a>
    &nbsp;&nbsp;&nbsp;&nbsp;<input type="button"  class="btn btn-default" value="数据差异"
                                   onclick="window.location.href='dbDiff?dbSource=' + o('dbSource').value;"/>
    &nbsp;&nbsp;&nbsp;&nbsp;<input type="button"  class="btn btn-default" value="数据字典"
                                   onclick="window.location.href='dbDict?dbSource=' + o('dbSource').value;"/>
    <br/><br/>
    （以本系统数据库为新版，与其它旧版系统比较，可在脚本设计器中定义数据源指向其它系统，数据源的定义保存于proxool.xml中）
</div>

<script th:inline="javascript">
    $('#dbSource').val("[(${dbSource})]");
</script>
<th:block th:if="${!isDbSource}">
<div style="margin:20px">
    <form id="formCreateTable" method="post">
        <strong>增加的表:</strong><br>
        <span th:utext="${add_table}"></span>
        <br>
        &nbsp;<input  class="btn btn-default" id="createTableBatch" type="submit" value="批量增加表"/><br/><br/>
    </form>
    <strong>删除的表:</strong><br>
    <span th:utext="${del_table}"></span>
    <br>
    <form id="formAddCol" method="post" >

        <strong>增加的列:</strong><br>
        <span th:utext="${add_column}"></span>
        <br>
        &nbsp;<input  class="btn btn-default" id="addColumnBatch" type="submit" value="批量增加列"/><br/><br/>
    </form>

    <strong>删除的列:</strong><br>
    <span th:utext="${del_column}"></span>
    <br>
    <form id="formAlterCol" method="post" >

        <strong>修改的列:</strong><br>
        <span th:utext="${change_column}"></span>
        <br>
        &nbsp;<input  class="btn btn-default" id="alterColumnBatch" type="submit" value="批量修改列"/><br/><br/>
    </form>

    旧系统版本
    <select id="version" name="version">
        <option value="4">4</option>
        <option value="5">5</option>
    </select>
    &nbsp;<input type="button"  class="btn btn-default" value="增加表单中的系统定义的列"
                 onclick="window.location.href='dbDiff?op=alterFormTable, dbSource=${dbSource}'"/><br/>
</div>
<script th:inline="javascript">
    $('#createTableBatch').click(function (e) {
        e.preventDefault();
        // window.location.href = 'db_diff';
        // return;

        $.ajax({
            type: "post",
            url: "createTable",
            data: {
                db: $('#oadb').val(),
            },
            dataType: "json",
            beforeSend: function (XMLHttpRequest) {
                $('body').showLoading();
            },
            success: function (res, status) {
                layer.alert(res.msg, {
                    yes: function () {
                        window.location.href = "db_diff";
                    }
                });
            },
            complete: function (XMLHttpRequest, status) {
                $('body').hideLoading();
            },
            error: function () {
                alert(XMLHttpRequest.responseText);
            }
        });
    })

    $('#addColumnBatch').click(function (e) {
        e.preventDefault();
        // window.location.href = 'db_diff';
        // return;

        $.ajax({
            type: "post",
            url: "addColumn",
            data: {
                db: $('#oadb').val(),
            },
            dataType: "json",
            beforeSend: function (XMLHttpRequest) {
                $('body').showLoading();
            },
            success: function (res, status) {
                layer.alert(res.msg, {
                    yes: function () {
                        window.location.href = "db_diff";
                    }
                });
            },
            complete: function (XMLHttpRequest, status) {
                $('body').hideLoading();
            },
            error: function () {
                alert(XMLHttpRequest.responseText);
            }
        });
    })

    $('#alterColumnBatch').click(function (e) {
        e.preventDefault();
        // window.location.href = 'db_diff';
        // return;

        $.ajax({
            type: "post",
            url: "alterColumn",
            data: {
                db: $('#oadb').val(),
            },
            dataType: "json",
            beforeSend: function (XMLHttpRequest) {
                $('body').showLoading();
            },
            success: function (res, status) {
                layer.alert(res.msg, {
                    yes: function () {
                        window.location.href = "db_diff";
                    }
                });
            },
            complete: function (XMLHttpRequest, status) {
                $('body').hideLoading();
            },
            error: function () {
                alert(XMLHttpRequest.responseText);
            }
        });
    })
    </script>
</th:block>
</body>
</html>
